﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MastePage/SubEmptyMaster.Master" AutoEventWireup="true" CodeBehind="PlanAdd.aspx.cs" Inherits="BySoft.Web.Site.Plan.PlanAdd" %>

<%@ MasterType VirtualPath="~/MastePage/SubEmptyMaster.master" %>
<%@ Register Assembly="OneSoft.Web" Namespace="OneSoft.Web.UI.WebControls" TagPrefix="asp" %>
<%@ Register Assembly="BySoft.Web.Controls" Namespace="BySoft.Web.Controls" TagPrefix="cc1" %>
<asp:Content ID="cphHeadContent" runat="server" ContentPlaceHolderID="HeadPlace">

    <script language="javascript" type="text/javascript">
        $(function () {
            $("#tabs").tabs({ show: function (event, ui) { iframeAutoFit(); } });
        });
        function FunAddProduct() {
            ShowTopDialog('选择产品', '../ComPage/QuerySProductByPlan.aspx', 'FillProess();', 1000, 600); return false;
        }
        function FillProess() {
            var str = getCookie(dialogReturn_key);
            if (str != null && str != "") {
                str = decodeURIComponent(str);
                var strs = str.split(',');
                if (undefined != strs[0]) {
                    document.getElementById("<%=txtWorkOrderNo.ClientID%>").value = strs[0];
                }
                if (undefined != strs[1]) {
                    document.getElementById("<%=txtProductID.ClientID%>").value = strs[1];
                }
                if (undefined != strs[2]) {
                    document.getElementById("<%=txtProductName.ClientID%>").value = strs[2];
                }
                if (undefined != strs[3]) {
                    document.getElementById("<%=txtUnit.ClientID%>").value = strs[3];
                }
                if (undefined != strs[4]) {
                    document.getElementById("<%=txtSpecifications.ClientID%>").value = strs[4];
                }
                if (undefined != strs[5]) {
                    document.getElementById("<%=txtCustomerPartNo.ClientID%>").value = strs[5];
                }
                if (undefined != strs[6]) {
                    document.getElementById("<%=txtOrderNum.ClientID%>").value = strs[6];
                }
                if (undefined != strs[7]) {
                    document.getElementById("<%=txtLastNum.ClientID%>").value = strs[7];
                    document.getElementById("<%=txtPlanNum.ClientID%>").value = strs[7];
                }
                if (undefined != strs[8]) {
                    document.getElementById("<%=txtInSide.ClientID%>").value = strs[8];
                }
                if (undefined != strs[9]) {
                    document.getElementById("<%=txtOutSide.ClientID%>").value = strs[9];
                }
                if (undefined != strs[10]) {
                    document.getElementById("<%=hdBOMID.ClientID%>").value = strs[10];
                }
            }
            document.getElementById("<%=btnHidden.ClientID%>").click();
            setCookie(dialogReturn_key, "");
        }
        function CheckNumWithDotOne(txtBox) {
            if (txtBox != null && txtBox.value != "") {
                var numFormat = /(^[0-9]\d{0,9}(\.\d{0,4})?$)/;
                var text = txtBox.value;
                if (!numFormat.test(text)) {
                    txtBox.value = 0;
                }
            }
        }
    </script>
</asp:Content>
<asp:Content ID="cphContent" runat="server" ContentPlaceHolderID="EmptyMasteCPH">
    <h1 class="tit">生产计划 >> <a href="PlanList.aspx">生产计划单>></a> 新增</h1>
    <br />
    <div class="tableStyle2">
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <table border="0" cellspacing="0" cellpadding="0" style="text-align: left; width: 100%"
                    id="tBase" runat="server">
                    <tr>
                        <th class="left2">号码</th>
                        <td class="right2">
                            <asp:Label ID="lblPlanID" runat="server" class="lblreadonly"></asp:Label></td>
                        <th class="left2">日期：</th>
                        <td class="right2">
                            <input class="Wdate" id="cpBillDate" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" readonly="true" runat="server" type="text"></input></td>
                    </tr>
                    <tr>
                        <th class="left2">制单号码：</th>
                        <td class="right2">
                            <asp:HiddenField ID="hdBOMID" runat="server" />
                            <asp:TextBox ID="txtWorkOrderNo" runat="server" class="lblreadonly"></asp:TextBox>
                            <span style="color: Red">*</span>
                            <asp:RequiredFieldValidator ControlToValidate="txtWorkOrderNo" ID="RequiredFieldValidator2" Display="None" runat="server" ErrorMessage="请选择工令号" ValidationGroup="gSubmit"></asp:RequiredFieldValidator>
                            <a style="cursor: pointer;" onclick="FunAddProduct()">
                                <img src="../App_Themes/Common_CSS/images/dot_14.gif" alt="" /></a>
                        </td>
                        <th class="left2">客户零件号：</th>
                        <td class="right2">
                            <asp:TextBox ID="txtCustomerPartNo" runat="server" class="lblreadonly"></asp:TextBox></td>
                    </tr>
                    <tr>
                        <th class="left2">产品编号：</th>
                        <td class="right2">
                            <asp:TextBox ID="txtProductID" runat="server" class="lblreadonly"></asp:TextBox></td>
                        <th class="left2">产品名称：</th>
                        <td class="right2">
                            <asp:TextBox ID="txtProductName" runat="server" class="lblreadonly"></asp:TextBox></td>
                    </tr>
                    <tr>
                        <th class="left2">规格：</th>
                        <td class="right2">
                            <asp:TextBox ID="txtSpecifications" runat="server" class="lblreadonly"></asp:TextBox></td>
                        <th class="left2">单位：</th>
                        <td class="right2">
                            <asp:TextBox ID="txtUnit" runat="server" class="lblreadonly"></asp:TextBox></td>
                    </tr><tr>
                        <th class="left2">内径：</th>
                        <td class="right2">
                            <asp:TextBox ID="txtInSide" runat="server" class="lblreadonly"></asp:TextBox></td>
                        <th class="left2">外径：</th>
                        <td class="right2">
                            <asp:TextBox ID="txtOutSide" runat="server" class="lblreadonly"></asp:TextBox></td>
                    </tr>
                    <tr>
                        <th class="left2">订单数量：</th>
                        <td class="right2">
                            <asp:TextBox ID="txtOrderNum" runat="server" class="lblreadonly"></asp:TextBox></td>
                        <th class="left2">剩余数量：</th>
                        <td class="right2">
                            <asp:TextBox ID="txtLastNum" runat="server" class="lblreadonly"></asp:TextBox></td>
                    </tr>
                    <tr>
                        <th class="left2">计划数量：</th>
                        <td class="right2">
                            <asp:TextBox ID="txtPlanNum" runat="server" class="fullHeight" onkeyup="CheckNumWithDotOne(this)" OnTextChanged="txtPlanNum_TextChanged" AutoPostBack="true"></asp:TextBox>
                            <span style="color: Red">*</span>
                            <asp:RequiredFieldValidator ControlToValidate="txtPlanNum" ID="RequiredFieldValidator1" Display="None" runat="server" ErrorMessage="请输入计划数量" ValidationGroup="gSubmit"></asp:RequiredFieldValidator>
                        </td>
                        <th class="left2"></th>
                        <td class="right2"></td>
                    </tr>
                    <tr>
                        <th class="left2">损耗余量：</th>
                        <td class="right2">
                            <asp:TextBox ID="txtLossNum" runat="server" class="fullHeight" onkeyup="CheckNumWithDotOne(this)"></asp:TextBox></td>
                        <th class="left2">加工属性：</th>
                        <td class="right2">
                            <asp:DropDownList ID="ddlProcessAttribute" runat="server" CssClass="fullHeight"></asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <th class="left2">使用已有成品库存数量：</th>
                        <td class="right2">
                            <asp:TextBox ID="txtUseStockNum" runat="server" onkeyup="CheckNumWithDotOne(this)" class="fullHeight"></asp:TextBox></td>
                        <th class="left2">直接生产数量：</th>
                        <td class="right2">
                            <asp:TextBox ID="txtProduceNum" runat="server" onkeyup="CheckNumWithDotOne(this)" class="fullHeight"></asp:TextBox>
                            <span style="color: Red">*</span>
                            <asp:RequiredFieldValidator ControlToValidate="txtProduceNum" ID="RequiredFieldValidator3" Display="None" runat="server" ErrorMessage="请输入直接生产数量" ValidationGroup="gSubmit"></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <th class="left2">备注：</th>
                        <td class="right2" colspan="3">
                            <asp:TextBox ID="txtRemark" runat="server" Width="99%" Height="50px" TextMode="MultiLine"></asp:TextBox>
                        </td>
                    </tr>
                </table>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
    <div>
        <div id="tabs">
            <ul>
                <li><a href="#tabs-1">材料计划明细</a></li>
            </ul>
            <div id="tabs-1" class="tableStyle">
                <asp:UpdatePanel ID="UpdatePanel4" runat="server">
                    <ContentTemplate>
                        <div style="width: 100%; padding-bottom: 10px">
                            <div align="right">
                                <label class="btnStylec png_bg">
                                    <asp:Button ID="btnHidden" runat="server" OnClick="btnHidden_Click" CssClass="Hidden" />
                                </label>
                            </div>
                        </div>
                        <div>
                            <asp:SGridView runat="server" ID="grdResult" Width="100%" ShowActionToolBar="false"
                                AutoGenerateColumns="false" AllowCascade="false" OnRowDataBound="grdResult_RowDataBound" OnRowCommand="grdResult_RowCommand">
                                <Columns>
                                    <asp:TemplateField HeaderText="材料计划明细编号" ItemStyle-CssClass="Hidden" FooterStyle-CssClass="Hidden" HeaderStyle-CssClass="Hidden">
                                        <ItemTemplate>
                                            <asp:Label ID="lblPlanDetailID" Text='<%#Eval("PlanDetailID") %>' runat="server"></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="BOM明细编号" ItemStyle-CssClass="Hidden" FooterStyle-CssClass="Hidden" HeaderStyle-CssClass="Hidden">
                                        <ItemTemplate>
                                            <asp:Label ID="lblBOMDetailID" Text='<%#Eval("BOMDetailID") %>' runat="server"></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="序号">
                                        <ItemTemplate>
                                            <%# Container.DisplayIndex+1 %>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="是否直接材料">
                                        <ItemTemplate>
                                            <asp:Label ID="lblIsDirect" Text='<%#Eval("IsDirect")%>' runat="server"></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="原料编号">
                                        <ItemTemplate>
                                            <div style="text-align: left">
                                                <asp:Label ID="lblMaterialID" Text='<%#Eval("MaterialID")%>' runat="server"></asp:Label>
                                            </div>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="原料品名">
                                        <ItemTemplate>
                                            <asp:Label ID="lblMaterialName" Text='<%#Eval("MaterialName") %>' runat="server"></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="长">
                                        <ItemTemplate>
                                            <asp:Label ID="lblLong" Text='<%#Eval("Long") %>' runat="server"></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="宽">
                                        <ItemTemplate>
                                            <asp:Label ID="lblWidth" Text='<%#Eval("Width") %>' runat="server"></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="高">
                                        <ItemTemplate>
                                            <asp:Label ID="lblHeight" Text='<%#Eval("Height") %>' runat="server"></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="外径">
                                        <ItemTemplate>
                                            <asp:Label ID="lblOutSide" Text='<%#Eval("OutSide") %>' runat="server"></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="内径">
                                        <ItemTemplate>
                                            <asp:Label ID="lblInSide" Text='<%#Eval("InSide") %>' runat="server"></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="规格">
                                        <ItemTemplate>
                                            <asp:Label ID="lblSpecifications" Text='<%#Eval("Specifications") %>' runat="server"></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="单位">
                                        <ItemTemplate>
                                            <asp:Label ID="lblUnit" Text='<%#Eval("Unit") %>' runat="server"></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="每米重量">
                                        <ItemTemplate>
                                            <asp:Label ID="lblMeterWeight" Text='<%#Eval("MeterWeight") %>' runat="server"></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="单件毫米数">
                                        <ItemTemplate>
                                            <asp:Label ID="lblMMNumber" Text='<%#Eval("MMNumber") %>' runat="server"></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="总数量（毫米数）">
                                        <ItemTemplate>
                                            <asp:Label ID="lblTotalNum" Text='<%#Eval("TotalNum") %>' runat="server" onkeyup="CheckNumWithDotOne(this);ChangePlanNum(this);" Width="80px"></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="总重量">
                                        <ItemTemplate>
                                            <asp:Label ID="lblTotalWeight" Text='<%#Eval("TotalWeight") %>' runat="server" onkeyup="CheckNumWithDotOne(this);ChangePlanNum(this);" Width="80px"></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField ItemStyle-CssClass="Hidden" HeaderStyle-CssClass="Hidden">
                                        <HeaderStyle Width="35px" />
                                        <HeaderTemplate>
                                            删除
                                        </HeaderTemplate>
                                        <ItemTemplate>
                                            <asp:ImageButton ImageUrl="../App_Themes/Common_CSS/images/delete_small.gif" runat="server"
                                                ID="ibtnDel" />
                                            <asp:Button ID="btnDel" runat="server" CssClass="Hidden" CommandArgument='<%#Eval("MaterialID") %>'
                                                CommandName="del" />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                </Columns>
                            </asp:SGridView>
                        </div>
                    </ContentTemplate>
                </asp:UpdatePanel>
            </div>
        </div>
    </div>
    <div class="controlBar" align="center">
        <table cellpadding="0" cellspacing="0" style="width: 300px; margin: 0 auto;">
            <tr>
                <td colspan="4">
                    <label class="btnStyleb png_bg">
                        <asp:Button ID="btnSubmit" runat="server" Text="确定" OnClick="btnSubmit_Click"
                            class="png_bg" />
                    </label>
                    <label class="btnStylec png_bg">
                        <input type="button" id="Button2" value="返回" runat="server" onclick="window.location = 'PlanList.aspx'"
                            class="png_bg" />
                    </label>
                </td>
            </tr>
        </table>
    </div>
</asp:Content>